package cn.jsj.onclock.pojo.identity;

import cn.jsj.onclock.exception.CustomException;
import lombok.extern.slf4j.Slf4j;

/**
 * 用户角色
 * @author 卢斌
 */
@Slf4j
public enum UserIdentityEnum {

    /**
     * 签到者
     */
    EXECUTOR,


    /**
     * 收集者
     */
    COLLECTOR,


    /**
     * 管理员
     */
    ADMINISTRATOR;


    /**
     * 检查身份信息是否可以创建群组
     */
    public static boolean hasCreateGroupPower(UserIdentityEnum identityEnum) {
        if (identityEnum == null) {
            throw new CustomException("身份验证信息为空");
        }
        return UserIdentityEnum.COLLECTOR.equals(identityEnum) || UserIdentityEnum.ADMINISTRATOR.equals(identityEnum);
    }


    /**
     * 检查身份信息是否可以录入签到标签
     */
    public static boolean hasPowerOfInputLabel(UserIdentityEnum identity) {
        if (identity == null) {
            throw new CustomException("身份验证信息为空");
        }
        return UserIdentityEnum.ADMINISTRATOR.equals(identity);
    }


    /**
     * 检查用户身份是否可以重命名签到标签
     */
    public static boolean hasPowerOfRenameLabel(UserIdentityEnum identity) {
        if (identity == null) {
            throw new CustomException("身份验证信息为空");
        }
        return UserIdentityEnum.ADMINISTRATOR.equals(identity);
    }


    /**
     * 检查用户是否具有查看其他用户发起的签到的完成情况的权限
     */
    public static boolean hasPowerOfCheckOthersSign(UserIdentityEnum identityEnum) {
        if (identityEnum == null) {
            throw new CustomException("无法获取用户身份信息");
        }
        return UserIdentityEnum.ADMINISTRATOR.equals(identityEnum);
    }



    public static boolean isExecutor(UserIdentityEnum identityEnum) {
        if (identityEnum == null) {
            throw new CustomException("无法获取用户身份信息");
        }
        return UserIdentityEnum.EXECUTOR.equals(identityEnum);
    }

    public static boolean isCollector(UserIdentityEnum identityEnum) {
        if (identityEnum == null) {
            throw new CustomException("无法获取用户身份信息");
        }
        return UserIdentityEnum.COLLECTOR.equals(identityEnum);
    }

    public static boolean isAdministrator(UserIdentityEnum identityEnum) {
        if (identityEnum == null) {
            throw new CustomException("无法获取用户身份信息");
        }
        return UserIdentityEnum.ADMINISTRATOR.equals(identityEnum);
    }


}
